package com.my.chapter18;

import java.io.*;

public class practice15 {
    static String file = ".\\src\\com\\my\\chapter18\\OutputPractice15.txt";
    public static void main(String[] args) throws IOException {
        DataOutputStream out = new DataOutputStream(
                new BufferedOutputStream(
                        new FileOutputStream(file)));
        out.writeBoolean(true);
        out.writeByte(100);
        out.writeByte(255);
        out.writeChar('A');
        out.writeFloat(1.41413f);
        out.writeLong(1000000000L);
        out.writeInt(100000);
        out.writeShort(30000);
        out.writeShort(65535);
        out.writeDouble(3.14159);
        out.writeUTF("That was pi");
        out.close();
        DataInputStream in = new DataInputStream(
                new BufferedInputStream(
                        new FileInputStream(file)));
        System.out.println(in.readBoolean());
        System.out.println(in.readByte());
        System.out.println(in.readUnsignedByte());
        System.out.println(in.readChar());
        System.out.println(in.readFloat());
        System.out.println(in.readLong());
        System.out.println(in.readInt());
        System.out.println(in.readShort());
        System.out.println(in.readUnsignedShort());
        System.out.println(in.readDouble());
        // Only readUTF() will recover the
        // Java-UTF String properly:
        System.out.println(in.readUTF());
    }
}
